package com.fy.fyzf.presenter;

import com.fy.fyzf.api.SubscriberCallBack;
import com.fy.fyzf.base.BasePresenter;
import com.fy.fyzf.bean.AreaListBean;
import com.fy.fyzf.bean.HomeBannerBean;
import com.fy.fyzf.bean.HousesBean;
import com.fy.fyzf.bean.HousesListBean;
import com.fy.fyzf.bean.BaseData;
import com.fy.fyzf.bean.HousingCountBean;
import com.fy.fyzf.bean.SearchPassengerBean;
import com.fy.fyzf.view.HouseSouceView;

import java.util.List;

public class HouseSoucePresenter extends BasePresenter<HouseSouceView> {

    public HouseSoucePresenter(HouseSouceView view) {
        super(view);
    }

    public void getHouseList(HousesBean housesBean){
        addSubscription(mApiService.getfloorList(housesBean), new SubscriberCallBack<BaseData<HousesListBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<HousesListBean> response) {
                mView.getHouseSuccess(response.data);
            }

            @Override
            protected void onError() {
                mView.onError();
            }
        });

    }

    public void getAreaList(Integer flag,Integer parentId){
        addSubscription(mApiService.listClassification(flag, parentId), new SubscriberCallBack<BaseData<List<AreaListBean>>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<List<AreaListBean>> response) {
                mView.getAreaListSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getSubwayData(int id){
        addSubscription(mApiService.findSubwayByParentId(id), new SubscriberCallBack<BaseData<List<AreaListBean>>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<List<AreaListBean>> response) {
                mView.getSubwatdataSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void addCollectHousing(SearchPassengerBean searchPassengerBean,int position){
        addSubscription(mApiService.addCollectHousing(searchPassengerBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.collectHousingSuccess(response,position);
            }

            @Override
            protected void onError() {

            }
        });
    }


    public void removeCollectionHousing(SearchPassengerBean searchPassengerBean, int position){
        addSubscription(mApiService.removeCollectHousing(searchPassengerBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.removecollectHousingSuccess(response,position);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getMatchHousingList(SearchPassengerBean searchPassengerBean,boolean isLoading){
        addSubscription(mApiService.getMatchHousingList(searchPassengerBean), new SubscriberCallBack<BaseData<HousesListBean>>(mView,isLoading) {
            @Override
            protected void onSuccess(BaseData<HousesListBean> response) {
                mView.getMatchHousingSuccess(response.data);
            }
            @Override
            protected void onError() {

            }
        });
    }

    public void getFloorCount(){
        addSubscription(mApiService.getHousingCount(0), new SubscriberCallBack<BaseData<HousingCountBean>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<HousingCountBean> response) {
                mView.getFloorCountSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void addIntegral(){
        addSubscription(mApiService.addIntegral(""), new SubscriberCallBack<BaseData>(mView,false) {
            @Override
            protected void onSuccess(BaseData response) {

            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getBanner(String s){
        addSubscription(mApiService.banner("index_banner"), new SubscriberCallBack<BaseData<List<HomeBannerBean>>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<List<HomeBannerBean>> response) {
                mView.getBannerSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }
}
